const Koa = require('koa')
const Router = require('koa-router')

const app = new Koa()
const usereRouter = new Router({ prefix: '/users' })

usereRouter.get('/', (ctx) => {
  ctx.body = '这是用户列表'
})

usereRouter.post('/', (ctx) => {
  ctx.body = '这是创建用户'
})

usereRouter.get('/:id', (ctx) => {
  ctx.body = `这是用户 ${ctx.params.id}`
})

// 任何中间都需要注册进去的
app.use(usereRouter.routes())

app.listen(3000)
